<?php
 /**
 * Application mobile mFinance
 */

require 'includes/class.Database.php';
require 'includes/class.Smarty.php';
require 'includes/class.Core.php';

//$db = Database::instance();
//$tpl = Template::instance();

$core = new Core;

$core->tpl->assign('siteName', 'mFinance');

if(isset($_COOKIE['account']) AND $_COOKIE['account'] != '')
{
	if(isset($_GET['module']) AND $_GET['module'] != '')
	{
		$module = basename($_GET['module']);
	
		if(file_exists("modules/$module.php"))
		{
		    include("modules/$module.php");
	    }
	    else
	    {
	        if(file_exists("templates/$module.tpl"))
	        {
	            $core->tpl->display("$module.tpl");
	        }
	        else
	        {
	            $core->tpl->display("error.tpl");
	        }
	    }
	} 
	else
	{
		include("modules/home.php");
	} 
}
else {
	include("modules/login.php");
}
?>
